package luogu;

import java.util.Scanner;

public class Main10 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] arr = new int[100];
        int count = 0 ; //记录数组中的数字个数
        //读取输入，直到遇到0
        while (true){
            int num = sc.nextInt();
            if (num==0){
                break;
            }
            //把数字放入数组中
            arr[count] = num;
            count++;
        }
        //倒序遍历数组中的数字
        for (int i = count - 1; i>=0  ; i--) {
            System.out.print(arr[i]);  //打印出来并不换行
            if (i>0){
                System.out.print(" ");
            }
        }
    }
}
